package compilador;
/**
 *  Clase que permite almacenar en un ArrayList una lista de nombres de nodos y luego sacar el String de cada uno.
 */
import java.awt.Color;
import java.util.ArrayList;

public class ListaNodos {
	
	public static final int END = 100;
	
	public static final int DO = 101;
	public static final int LOOP = 102;
	public static final int WHILE = 103;
	
	public static final int EXIT = 104;
	public static final int FUNCTION = 105;
	
	public static final int IF = 106;
	public static final int THEN = 107;
	public static final int ELSEIF = 108;
	public static final int ELSE = 109;
	
	public static final int LOCATE = 110;
	public static final int PRINT = 111;
	public static final int INPUT = 112;
	public static final int CLS = 113;
	
	public static final int DIM = 114;
	public static final int COMA = 115;	
	public static final int AS = 116;
	public static final int IDENTIFICADOR = 117;
	public static final int PAR_ABIERTO = 118;
	public static final int PAR_CERRADO = 119;
	public static final int INTEGER = 120;
	public static final int LONG = 121;
	public static final int SINGLE = 122;
	public static final int DOUBLE = 123;
	public static final int STRING = 124;
	public static final int PR_INTEGER = 125;
	public static final int PR_LONG = 126;
	public static final int PR_SINGLE = 127;
	public static final int PR_DOUBLE = 128;
	public static final int PR_STRING = 129;
	public static final int TYPE = 130;
	public static final int DECLARE = 131;
	public static final int STATIC = 132;
	public static final int PUNTO = 133;
	
	public static final int OP_ASIG = 134;
	public static final int OP_LOG_BIN = 135;
	public static final int OP_LOG_UNA = 136;
	public static final int OP_COMP = 137;
	public static final int OP_SUM = 138;
	public static final int OP_MUL = 139;
	public static final int CONST = 140;

	
	public static final String TXT_VALOR[] = {
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"","","","","","","","","","",
		"END", "DO", "LOOP", "WHILE",
		"EXIT", "FUNCTION", "IF", "THEN",
		"ELSEIF", "ELSE", "LOCATE", "PRINT",
		"INPUT", "CLS", "DIM", "Coma", 
		"AS", "Identificador", "Par_abierto", "Par_cerrado",
		"Integer", "Long", "Single", "Double",
		"String", "PR_INTEGER", "PR_LONG", "PR_SINGLE",
		"PR_DOUBLE", "PR_STRING", "TYPE", "DECLARE",
		"STATIC", "Punto", "OP_ASIG", "OP_LOG_BIN",
		"OP_LOG_UNA", "OP_COMP", "OP_SUM", "OP_MUL",
		"CONST"
	};
	
	private static ArrayList<Integer> reglas = new ArrayList<Integer>();
	
	public ListaNodos(){
		reglas=new ArrayList<Integer>();
	}
	
	public static void reinicia(){
		reglas= new ArrayList<Integer>();
	}
	
	public static void add(int regla){
		reglas.add(regla);
	}
	
	public static String get(int i){
		int v= reglas.get(i);
		return TXT_VALOR[v];
	}
	
	public static Color getColor(int nodo){
		Color color = null;
		
		// Regla -> Verde claro
		if (esRegla(nodo)) color = new Color(125,255,125);
		// Token -> Azul claro
		else if (esToken(nodo)) color = new Color(125,125,255);
		else color = new Color(200,0,0);
		
		return color;
	}
	
	public static boolean esRegla(int nodo){
		return (nodo >= 0 && nodo < 100);
	}
	
	public static boolean esToken(int nodo){
		return (nodo >= 100);
	}
	
	public static int size(){return reglas.size();}
	
	

}
